<!-- 大学列表 -->
<template>
	<view class="condition">
		<view class="contents">
			<view class="lists">
				<view class="content-item" v-for="(item,index) of schoolList" :key="item.id" @click.stop="handleClick(item)">
					<view class="flex">
						<view class="classFy font12" v-if="item.schoolClassify" :style="`background: `+colorList[item.schoolClassify]">{{item.schoolClassify}}</view>
						<!-- 左侧图片 -->
						<view class="left">
							<image :src="item.logo" mode="widthFix"></image>
							<view class="font12 bold yearTxt">{{searchParam.year}}</view>
						</view>
						
						<!-- 右侧数据 -->
						<view class="right">
							<view class="title font12 hiddenOneline">
								<span class="font16 bold schoolName">{{item.schoolName}}</span> 
								{{item.collegeName}}
							</view>
							<view class="normal-title font12 bold">{{ item.majorCode + '' + item.majorName }}</view>
							
							<view class="type flex flexWrap">
								<view class="name font12" v-for="(val,index1) of item.schoolType.split(',')" :key="index1">{{val}}</view>
							</view>
							
							<view class="area-name font12 flex">
								<uni-icons type="location-filled" size="16" color="#7f7f7f"></uni-icons>
								<!-- <image src="@/static/image/icons/area.png" mode="widthFix"></image> -->
								{{item.provinceName}}
							</view>
						</view>
					</view>
					
					<view class="btns u-font-28 flex justify-around">
						<view class="flex align-center" @click.stop="handleB(item)">
							<u-icon size="28" class="u-m-r-10"
								name="https://aihelp.oss-cn-hangzhou.aliyuncs.com/public/base/2023/11/11/fcec3e172ffc43838ba60ae8fa67cba6.png"></u-icon>
								专业详情
						</view>
						<view class="flex align-center" @click.stop="handleClick(item)">
							<u-icon size="28" class="u-m-r-10"
								name="https://aihelp.oss-cn-hangzhou.aliyuncs.com/public/base/2023/12/05/64acfa49074c404d966a41d71e09c667.png"></u-icon>
								大学详情
						</view>
						
						<view class="flex align-center" @click.stop="handAdd(item)">
							<u-icon size="28" class="u-m-r-10"
								name="https://aihelp.oss-cn-hangzhou.aliyuncs.com/public/base/2023/11/11/87c15603db764305a3d982f62e1f5ada.png"></u-icon>
								加入对比库
						</view>
					</view>
					<!-- <view class="btns font12 flex align-center justify-evenly u-m-t-30">
						<view class="icon flex alignCenter" @click.stop="handleB(item)"><image src="https://aihelp.oss-cn-hangzhou.aliyuncs.com/kwkd/resources/front/homePage/icon3.png" mode="widthFix"></image> 专业详情</view>
						<view class="icon flex alignCenter" @click.stop="handleClick(item)"><image src="https://aihelp.oss-cn-hangzhou.aliyuncs.com/kwkd/resources/front/homePage/icon4.png" mode="widthFix"></image>大学详情</view>
						<view class="icon flex alignCenter" @click.stop="handAdd(item)"><image src="https://aihelp.oss-cn-hangzhou.aliyuncs.com/kwkd/resources/front/homePage/icon6.png" mode="widthFix"></image>加入对比库</view>
					</view> -->
				</view>
			
			</view>
		</view>
		
		<view class="no-data" v-if="schoolList.length<=0">
			<image src="http://image.alhelp.net/uploads/20231104/8d4f88d27dfddc10b427fbe997780eaf.png"></image>
			<view class="font14 color999">暂无数据</view>
		</view>
		<view v-else-if="schoolList.length>=total" class="font12 noMore-data"> - 没有更多数据了 - </view>
	</view>
</template>

<script>
	import { getProvince,getSubject,getMajorBySubject,addMyContrast} from "@/api/index.js"
	
	import { listByConditions,selectList} from "@/api/toolbox.js"
	export default {
		data() {
			return {
				popType: 1,
				total: 0,
				searchParam: {
					areaId: "",
					exam: "",
					examCode: "",
					examList: [],
					majorStar: "",
					pageNum: 1,
					pageSize: 10,
					passScoreSection: [],
					schoolClassify: "",
					schoolCodeList: null,
					schoolType: "",
					studyType: "",
					subjectCode: "",
					subjectOneCode: "",
					majorCode: "",
					subjectOneStar: "",
					subjectStar: "",
					year: '',
					isKwkd:true,
				},
				direction: '',
				colorList: {
					'综合':'rgba(250, 205, 145, 0.6)',
					'理工':'rgba(2, 167, 240, 0.6)',
					'财经':'rgba(194, 128, 255, 0.6)',
					'医药':'rgba(236, 128, 141, 0.6)',
					'民族':'rgba(25, 204, 165, 0.6)',
					'农林':'rgba(168,186,4,0.6)',
					'师范':'rgba(8,164,54,0.62)',
					'体育': 'rgba(24,47,198,0.62)',
					'文法': 'rgba(192,23,118,0.62)',
					'艺术': 'rgba(20,97,119,0.62)'
				},
				schoolList: [],
			}
		},
		
		onLoad(options) {
			if(JSON.parse(options.item)){
				if(options.item){
					let item = JSON.parse(options.item);
					this.searchParam.year = item.year;
					this.searchParam.examCode = item.examCode;
					this.searchParam.direction = item.direction;
					this.searchParam.majorCode = item.majorCode;
					this.searchParam.studyType = item.studyType;//学习形式
					if(item.schoolCodeList){
						this.searchParam.schoolCodeList = item.schoolCodeList
					}
				}
				
			}
			this.getData();
		},
		methods: {
			// 报录比
			handleB(item){
				console.log(item);
				let items = {
					"collegeCode": item.collegeCode, //"023"
					"majorCode": item.majorCode, //"010101"
					"schoolCode": item.schoolCode, //"10001"
				}
				uni.navigateTo({
					url: `/pages/toolbox/chooseMajor/major/majorDetail?items=${JSON.stringify(items)}`
				})
			},
			getData(){
				uni.showLoading({
					title: '加载中'
				})
				listByConditions(this.searchParam).then((res)=>{
					console.log(res);
					uni.hideLoading()
					if(res.code==100000){
						if(this.searchParam.pageNum == 1){
							this.schoolList = res.data.rows;
							this.total = res.data.total;
							return
						}
						this.schoolList.push.apply(this.schoolList,res.data.rows);	
					}
				}).catch(()=>{
					uni.hideLoading()
				})
			},
			
			
			handleClick(item){
				uni.navigateTo({
					url: `/pages/toolbox/chooseMajor/school/schoolDetail?schoolCode=${item.schoolCode}&title=${item.schoolName}`
				})
			},
			// 加入对比库
			handAdd(item){
				addMyContrast({
					collegeCode: item.collegeCode,
					createTime: item.createTime,
					isDel: 0,
					majorCode: item.majorCode,
					schoolCode: item.schoolCode,
					updateTime: item.updateTime,
					year: item.year,
				}).then(res=>{
					console.log(res);
					if(res.code == 100000){
						uni.showToast({
							title: '加入对比库成功',
							icon: 'none'
						})
					}
				})
			},
			//底部刷新
			onReachBottom() {
				if(this.schoolList.length>=this.total) return;
				this.searchParam.pageNum++;
				this.getData();
			}
			
		},
		
	}
</script>

<style lang="scss" scoped>
	page{
		background: #f2f2f2;
	}
	.condition{
		// height: 100%;
		// background: #f2f2f2;
		// min-height: 100vh;
		.contents{
			// margin-top: 30rpx;
			.lists{
				padding-top: 30rpx;
				.content-item{
					background: #ffffff;
					margin: 0 30rpx 40rpx;
					border-radius: 30rpx;
					box-shadow: 0 0 12rpx rgba(0, 0, 0, .3);
					padding-bottom: 80rpx;
					
					.classFy{
						// position: absolute;
						margin-bottom: 8rpx;
						width: 100rpx;
						height: 52rpx;
						line-height: 52rpx;
						background: rgba(25, 204, 165, 0.6);
						border-radius: 30rpx;
						border-top-right-radius: 0px;
						border-bottom-left-radius: 0px;
						color: #FFFFFF;
						text-align: center;
						position: absolute;
						z-index: 1;
					}
					
					.left{
						margin: auto 0;
						image{
							width: 160rpx;
							height: 160rpx;
							border-radius: 50%;
							margin: 0 30rpx
						}
						.yearTxt{
							text-align: center;
							line-height: 1em;
							margin-top: 10rpx;
						}
					}
					.right{
						// margin-left: 48rpx;
						.title{
							margin: 30rpx 10rpx 20rpx 0;
							font-style: normal;
							color: #333333;
							.schoolName{
								margin-right: 20rpx;
							}
						}
					
						.normal-title{
							margin: 4rpx 0;
						}
						
						.type{
							margin-top: 10rpx;
							.name{
								color: #333;
								border: 1px solid rgba(247, 221, 94, 1);
								background: rgba(247, 221, 94, 0.1);
								border-radius: 30rpx;
								padding: 0 10rpx;
								margin: 0 10rpx 10rpx 0;
							}
						}
						
						.area-name{
							color: #7F7F7F;
							// padding-top: 20rpx;
							align-items: center;
							// justify-content: center;
							
							image{
								width: 30rpx;
								height: 30rpx;
								margin: 0 10rpx
							}
						}
						
					}
					
					.add-btn{
						width: 200rpx;
						height: 80rpx;
						background-color: rgba(247, 221, 94, 0.8);
						border-radius: 30rpx;
						border-top-right-radius: 0px;
						border-bottom-left-radius: 0px;
						color: #000000;
						align-items: center;
						justify-content: center;
						position: absolute;
						right: 30rpx;
						// margin-top: -10rpx;
					}
				}
			}
			
		}
		.no-data{
			text-align: center;
			margin-top: 120rpx;
			image{
				width: 120rpx;
				height: 120rpx;
			}
		}
		.noMore-data{
			text-align: center;
			color: #afafaf;
			padding-bottom: 20rpx;
		}
		
		.pickerLayer{
			position:fixed;
			top:0;
			left:0;
			width: 100%;
			height: 100%;
			background:rgba(0,0,0,.15);
			z-index: 2;
			.layerMain{
				position: absolute;
				bottom:0;
				left: 0;
				width:100%;
				height:1000rpx;
				padding:30rpx 0;
				box-sizing: border-box;
				border-radius: 40rpx 40rpx 0 0;
				background: #fff;
			}
			.layerTitle{
				text-align: center;
				position: relative;
				.layerClose{
					position: absolute;
					right: 30rpx;
					bottom: 0;
				}
			}
			.chooseBox{
				margin: 30rpx 0 0;
				padding:0 30rpx;
				box-sizing: border-box;
				border-bottom: 1px solid $bordercolor;
				height:80rpx;
				line-height: 80rpx;
				.commonChoose{
					padding: 0 40rpx;
					flex-shrink: 0;
				}
				.activeLayerStyle{
					border-bottom:2px solid $colorMain;
				}
			}
			.dataBox{
				.dataScroll{
					height:800rpx;
					overflow-y: scroll;
				}
				.scrollItem{
					padding: 0 30rpx;
					height: 100rpx;
					line-height: 100rpx;
					box-sizing: border-box;
					position: relative;
					
				}
				.activeIcon{
					color: $colorMain !important;
					position: absolute;
					right: 30rpx;
					bottom: 0;
				}
			}
		}
		
		
		
		
		
		.popup-box{
			background: #fff;
			border-top-left-radius: 30rpx;
			border-top-right-radius: 30rpx;
			padding: 30rpx;
		
		
			.btns {
				margin-top: 28rpx;
				align-items: center;
				view{
					background-color: #F9F9F9;
					border-radius: 100rpx;
					color: #000;
					padding: 20rpx 30rpx;
				}
				.btn1,
				.btn2,
				.btn3 {
					// background-color: rgba(247, 221, 94, 1);
					width: 194rpx;
					height: 72rpx;
					align-items: center;
					justify-content: center;
					// margin-right: 20rpx;
					color: #333;
					// border-radius: 50rpx;
				}
			
				image {
					width: 32rpx;
					height: 32rpx;
					margin-right: 8rpx;
				}
			
				.btn3 {
					margin-right: 0px;
				}
			}
			
			.search-contents{
				text-align: center;
				line-height: 70rpx;
				overflow-x: hidden;
				height: 500rpx;
				// background: #F7DD5E;
				
				.chooseItem{
					background-color: rgba(253,224,128,0.3);
				}
			}
			
		}
		
		
	}
	
	
	.icon{
		image{
			width: 32rpx;
			height: 32rpx;
			margin-right: 8rpx;
		}
	}
</style>